<template>
  <!-- 异常处理审核明细-->
  <el-dialog
    :title="title"
    center
    :visible.sync="openState"
    width="1024px"
    :close-on-click-modal="false"
    :before-close="handleClose"
  >
    <el-form ref="form" :model="form" :rules="rules" :disabled="true" label-width="130px">
      <!--异常处理审核明细-->

      <el-row>
        <el-col :span="12">
          <el-form-item label="原交易流水号" prop="txnId">
            <el-input v-model="form.txnId" placeholder="原交易流水号" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="系统编号" prop="sysCode">
            <el-select v-model="form.sysCode" placeholder="系统编号">
              <el-option
                v-for="dict in dictMap.SYSTEMCODE"
                :key="dict.value"
                :label="`${dict.value}-${dict.text}`"
                :value="dict.value"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="12">
          <el-form-item label="工作日期" prop="workdate">
            <el-date-picker style="width: 100%" v-model="form.workdate" value-format="yyyyMMdd" type="date" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="CPG日期" prop="cpgdate">
            <el-date-picker style="width: 100%" v-model="form.cpgdate" value-format="yyyyMMdd" type="date" />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="12">
          <el-form-item label="来往账标识" prop="drct">
            <el-select v-model="form.drct" placeholder="来往账标识" style="width: 100%">
              <el-option
                v-for="dict in dictMap.DRCTCODE"
                :key="dict.value"
                :label="`${dict.value}-${dict.text}`"
                :value="dict.value"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="报文类型" prop="pkgNo">
            <el-select
              style="width: 100%"
              v-model="form.pkgNo === null || form.pkgNo === undefined ? '' : form.pkgNo + '-' + form.pkgNoDesc"
              placeholder="报文类型"
            ></el-select>
          </el-form-item>
        </el-col>

      </el-row>

      <el-row>
        <el-col :span="12">
          <el-form-item label="异常类型" prop="exceptionType">
            <el-select v-model="form.exceptionType" placeholder="异常类型" style="width: 100%">
              <el-option
                v-for="dict in dictMap.EXCEPTION_TYPE"
                :key="dict.value"
                :label="`${dict.value}-${dict.text}`"
                :value="dict.value"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="通讯级标识号" prop="msgId">
            <el-input v-model="form.msgId" placeholder="通讯级标识号" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item label="发送/接收时间" prop="sndRcvTime">
            <el-date-picker
              style="width: 100%"
              v-model="form.sndRcvTime"
              value-format="yyyyMMddHHmmss"
              type="datetime"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="异常处理类型" prop="opType">
            <el-select v-model="form.opType" placeholder="异常处理类型" style="width: 100%">
              <el-option
                v-for="dict in dictMap.EXCEPTION_OPTYPE"
                :key="dict.value"
                :label="`${dict.value}-${dict.text}`"
                :value="dict.value"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>

        <el-col :span="12">
          <el-form-item label="业务处理码" prop="procCodeDesc">
            <el-input v-model="form.procCodeDesc" placeholder="业务处理码" />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="24">
          <el-form-item label="业务拒绝信息" prop="rejectInfo">
            <el-input v-model="form.rejectInfo" placeholder="业务拒绝信息" type="textarea" />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="12">
          <el-form-item label="录入操作员" prop="mdTlrno">
            <el-input v-model="form.mdTlrno" placeholder="录入操作员" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="录入时间" prop="mdTime">
            <el-date-picker style="width: 100%" v-model="form.mdTime" value-format="yyyyMMddHHmmss" type="datetime" />
          </el-form-item>
        </el-col>
      </el-row>

    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="approve">审 核</el-button>
      <el-button type="primary" @click="reject">拒 绝</el-button>
    </div>
  </el-dialog>
</template>
<script>
import {
  exceptionHandlingApproveDetail,
  exceptionHandlingApprove,
  exceptionHandlingReject,
} from "@/api/cnaps/bizMng/exceptionHandling.js";
import { listPageMixin } from "@/libs/listPageMixin";

export default {
  name: "exceptionHandlingDialog",
  mixins: [listPageMixin],
  components: {},
  data() {
    return {
      title: "",
      // 是否显示弹出层
      openState: false,
      // 字段可编辑控制

      //数据字典
      searchFormDictList: ["SYSTEMCODE", "DRCTCODE", "EXCEPTION_TYPE", "EXCEPTION_OPTYPE"],
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
      opButtonList: () => {
        return [];
      },
    };
  },
  mounted() {},
  methods: {
    // 表单重置
    reset() {
      this.resetForm("form");
      this.$set(this, "form", {});
    },
    // 关闭回掉
    handleClose(done) {
      this.$confirm("确认关闭？")
        .then((_) => {
          this.reset();
          done();
        })
        .catch((_) => {});
    },
    show(row) {
      this.form = row;
      this.title = "异常处理审核明细";
      this.openState = true;

      this.exceptionHandlingApproveDetail(row);
    },

    exceptionHandlingApproveDetail: function (row) {
      exceptionHandlingApproveDetail(row).then((response) => {
        this.showData(response);
      });
    },
    showData: function (response) {
      this.form = response.result.data;
    },

    /** TODO审批按钮 */
    approve() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          exceptionHandlingApprove(this.form).then((res) => {
            if (res.code === "S") {
              this.msgSuccess("审批通过");
              this.cancel();
            }
          });
        }
      });
    },

    /** TODO拒绝按钮 */
    reject() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          exceptionHandlingReject(this.form).then((res) => {
            if (res.code === "S") {
              this.msgSuccess("审批已拒绝");
              this.cancel();
            }
          });
        }
      });
    },

    cancel() {
      this.openState = false;
      this.reset();
      this.$emit("editComplete", true);
    },
  },
};
</script>
<style>
.label-header-msg {
  font-weight: bold;
}

.form-card {
  margin-bottom: 10px;
}
</style>
